import requests


class EmpApi:
    #1.添加员工接口
    @classmethod
    def add_emp_api(cls,token,body):
        url="http://ihrm2-test.itheima.net/api/sys/user"
        headers={"Content-Type":"application/json", "Authorization":token}
        resp=requests.post(url=url,headers=headers,json=body)
        return resp
    #2.查询员工接口
    @classmethod
    def query_emp_api(cls,token,emp_id):
         url = f"htt p://ihrm2-test.itheima.net/api/sys/user/{emp_id}"
         headers = {"Content-Type": "application/json", "Authorization": token}
         resp = requests.get(url=url, headers=headers)
         return resp
    #3.修改员工接口
    @classmethod
    def put_emp_api(cls,emp_id,body,token):
        put_emp_url = f'http://ihrm2-test.itheima.net/api/sys/user/{emp_id}'
        put_emp_header = {"Content-Type": "application/json", "Authorization": token}
        put_resp = requests.put(url=put_emp_url, headers=put_emp_header, json=body)
        return put_resp
     #4.删除员工接口
    @classmethod
    def del_emp_api(cls,emp_id,token):
        del_emp_url = f'http://ihrm2-test.itheima.net/api/sys/user/{emp_id}'
        del_emp_header = {"Authorization": token}
        del_resp = requests.delete(url=del_emp_url, headers=del_emp_header)
        return del_resp